package com.tepth.remote.core.app;

import android.app.AlarmManager;
import android.content.Context;
import android.os.Handler;

/**
 * Description:全局配置类
 *
 * @author Hequn.Lee
 * @date 2018/11/7
 */
public final class Control {

    /**
     * 配置文件全局初始化
     *
     * @param context 全局上下文
     * @return 配置文件类
     */
    public static Configurator init(Context context) {
        Configurator.getInstance()
                .getControlConfigs()
                .put(ConfigKeys.APPLICATION_CONTEXT, context.getApplicationContext());
        return Configurator.getInstance();
    }

    private static Configurator getConfigurator() {
        return Configurator.getInstance();
    }

    public static <T> T getConfiguration(Object key) {
        return getConfigurator().getConfiguration(key);
    }

    public static Context getApplicationContext() {
        return getConfiguration(ConfigKeys.APPLICATION_CONTEXT);
    }

    public static Handler getHandler() {
        return getConfiguration(ConfigKeys.HANDLER);
    }

    public static AlarmManager getAlarmManager() {
        return getConfiguration(ConfigKeys.ALARM_MANAGER);
    }
}
